const express = require("express");
const multer = require("multer");

let server = express();
server.listen(8080);

let storage = multer.diskStorage({
  destination:"./upload/",
  filename: function (req, file, cb) {
    let index = file.originalname.lastIndexOf(".")
    let huozui  = file.originalname.slice(index);
    //cb(null, uuid().replace(/-/gi,"")+huozui);
    cb(null, Date.now()+huozui);
  }
})

let multerObj = multer({ storage: storage })
/*let multerObj=multer({dest: './../web/demo/'});*/
//let multerObj=multer({dest: './upload/'});
server.use(multerObj.any());

server.use("/a",(req,res,next)=>{
  console.log(req.files)
  res.send("上传成功")
});

server.use(express.static("./webapps/"));
